home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------
- | FILE NAME: ListTest.c
- |
- | DOCUMENT: [1032.0]
- |
- | PURPOSE: To test and demonstrate the use of the 'ListList'
- | linked list system.
- |
- | DESCRIPTION: Every procedure in the 'ListList' product is
- | validated using automated testing. Known values are given
- | to each procedure and tests are made for expected results.
- | Test results are reported to the display and to the file
- | 'ListTest.txt'. Some tests require visual validation.
- |
- | NOTE:
- |
- | HISTORY: 11.04.93 Created by Lee Malone
- ------------------------------------------------------------*/
-
- #include <ListList.h>
-
- Item TestItem[1] = { (AddressOfItem) 2,
- (AddressOfItem) 4,
- (AddressOfByte) 6,
- (Pair) 8 };
-
- List TestList[1] = { (AddressOfItem) 10,
- (AddressOfItem) 12,
- (Quad) 14,
- (Pair) 16 };
- FILE *LogFile;
-
- typedef struct
- {
- AddressOfTruthProcedure TestProcedure;
- AddressOfString NameOfProcedure;
- } TestRecord, *AddressOfTestRecord;
-
- /*------------------------------------------------------------
- | NAME: Test_Byte
- |
- | PURPOSE: To test the 'Byte' data type.
- |
- | DESCRIPTION: Returns non-zero, if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.08.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_Byte()
- {
- Comparison Result;
- Byte AByte;
- Byte ByteTable[2] = { 1, 2 };
- AddressOfByte ByteAddress;
-
- if(sizeof(Byte) != 1) return(1);
-
- Result = ByteTable[0] - 1;
- if(Result != 0) return(2);
-
- Result = ByteTable[1] - 2;
- if(Result != 0) return(3);
-
- ByteAddress = ByteTable;
- Result = ByteTable[0] - *ByteAddress;
- if(Result != 0) return(4);
-
- AByte = 250; /* a 'Byte' is unsigned */
- if(AByte < 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_Pair
- |
- | PURPOSE: To test the 'Pair' data type.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.08.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_Pair()
- {
- Comparison Result;
- Pair APair;
- Pair PairTable[2] = { 0, 1 };
- AddressOfPair PairAddress;
-
- if(sizeof(Pair) != 2) return(1);
-
- Result = PairTable[0] - 0;
- if(Result != 0) return(2);
-
- Result = PairTable[1] - 1;
- if(Result != 0) return(3);
-
- PairAddress = PairTable;
- Result = PairTable[0] - *PairAddress;
- if(Result != 0) return(4);
-
- APair = 35000; /* a 'Pair' is unsigned */
- if(APair < 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_Quad
- |
- | PURPOSE: To test the 'Quad' data type.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.08.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_Quad()
- {
- Comparison Result;
- Quad AQuad;
- Quad QuadTable[2] = { 0, 1 };
- AddressOfQuad QuadAddress;
-
- if(sizeof(Quad) != 4) return(1);
-
- Result = QuadTable[0] - 0;
- if(Result != 0) return(2);
-
- Result = QuadTable[1] - 1;
- if(Result != 0) return(3);
-
- QuadAddress = QuadTable;
- Result = QuadTable[0] - *QuadAddress;
- if(Result != 0) return(4);
-
- AQuad = 2200000000; /* a 'Quad' is unsigned */
- if(AQuad < 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SignedByte
- |
- | PURPOSE: To test the 'SignedByte' data type.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.09.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SignedByte()
- {
- Comparison Result;
- SignedByte ASignedByte;
- SignedByte SignedByteTable[2] = { -1, 1 };
- AddressOfSignedByte ASignedByteAddress;
-
- if(sizeof(SignedByte) != 1) return(1);
-
- Result = SignedByteTable[0] + 1;
- if(Result != 0) return(2);
-
- Result = SignedByteTable[1] - 1;
- if(Result != 0) return(3);
-
- ASignedByteAddress = SignedByteTable;
- Result = SignedByteTable[0] - *ASignedByteAddress;
- if(Result != 0) return(4);
-
- ASignedByte = 250; /* A 'SignedByte' must be in the range
- * +/- 127, so '250' should be
- * interpreted as a negative number.
- */
- if(ASignedByte > 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SignedPair
- |
- | PURPOSE: To test the 'SignedPair' data type.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.09.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SignedPair()
- {
- Comparison Result;
- SignedPair ASignedPair;
- SignedPair SignedPairTable[2] = { 0, -1 };
- AddressOfSignedPair ASignedPairAddress;
-
- if(sizeof(SignedPair) != 2) return(1);
-
- Result = SignedPairTable[0] - 0;
- if(Result != 0) return(2);
-
- Result = SignedPairTable[1] + 1;
- if(Result != 0) return(3);
-
- ASignedPairAddress = SignedPairTable;
- Result = SignedPairTable[0] - *ASignedPairAddress;
- if(Result != 0) return(4);
-
- ASignedPair = 35000;
- if(ASignedPair > 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SignedQuad
- |
- | PURPOSE: To test the 'SignedQuad' data type.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.09.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SignedQuad()
- {
- Comparison Result;
- SignedQuad ASignedQuad;
- SignedQuad SignedQuadTable[2] = { 0, -1 };
- AddressOfSignedQuad ASignedQuadAddress;
-
- if(sizeof(SignedQuad) != 4) return(1);
-
- Result = SignedQuadTable[0] - 0;
- if(Result != 0) return(2);
-
- Result = SignedQuadTable[1] + 1;
- if(Result != 0) return(3);
-
- ASignedQuadAddress = SignedQuadTable;
- Result = SignedQuadTable[0] - *ASignedQuadAddress;
- if(Result != 0) return(4);
-
- ASignedQuad = 2200000000; /* a 'SignedQuad' is signed */
- if(ASignedQuad > 0) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CompareBytes
- |
- | PURPOSE: To test the 'CompareBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast the count parameters of 'CompareBytes'
- | to be a 'Quad' to avoid errors when using 'Think C'.
- |
- | ASSUMES:
- |
- | HISTORY: 11.04.93 by Lee Malone
- |
- ------------------------------------------------------------*/
-
- Truth
- Test_CompareBytes()
- {
- Comparison Result;
- Byte ABytes[] = { 1, 1, 1, 1 };
- Byte BBytes[] = { 1, 1, 1, 8, 1 };
- Byte CBytes[] = { 1, 1, 1, 1, 2, 1 };
-
- Result = CompareBytes( ABytes, (Quad) 4, BBytes, (Quad) 5 );
- if(Result >= 0) return(1);
-
- Result = CompareBytes( ABytes, (Quad) 4, CBytes, (Quad) 6 );
- if(Result >= 0) return(2);
-
- Result = CompareBytes( BBytes, (Quad) 5, CBytes, (Quad) 6 );
- if(Result <= 0) return(3);
-
- return(0);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CopyBytes
- |
- | PURPOSE: To test the 'CopyBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast literal count parameters to be a 'Quad'
- | to avoid errors when using 'Think C'.
- |
- | ASSUMES:
- |
- | HISTORY: 11.10.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CopyBytes()
- {
- Byte ABytes[] = { 1, 2, 3, 4 };
- Byte BBytes[] = { 0, 0, 0, 0, 0, 0 };
- Byte CBytes[] = { 5, 6, 7, 8 };
-
- /* Copy ABytes into middle of BBytes */
- CopyBytes( ABytes, &BBytes[1], (Quad) 4 );
- if(BBytes[0] != 0) return(1);
- if(BBytes[1] != 1) return(2);
- if(BBytes[2] != 2) return(3);
- if(BBytes[3] != 3) return(4);
- if(BBytes[4] != 4) return(5);
- if(BBytes[5] != 0) return(6);
-
- /* Copy CBytes into middle of BBytes */
- CopyBytes( CBytes, &BBytes[1], (Quad) 4 );
- if(BBytes[0] != 0) return(7);
- if(BBytes[1] != 5) return(8);
- if(BBytes[2] != 6) return(9);
- if(BBytes[3] != 7) return(10);
- if(BBytes[4] != 8) return(11);
- if(BBytes[5] != 0) return(12);
-
- /* Copy last 4 bytes of BBytes into the first 4 */
- CopyBytes( &BBytes[2], BBytes, (Quad) 4);
- if(BBytes[0] != 6) return(13);
- if(BBytes[1] != 7) return(14);
- if(BBytes[2] != 8) return(15);
- if(BBytes[3] != 0) return(16);
- if(BBytes[4] != 8) return(17);
- if(BBytes[5] != 0) return(18);
-
- /* Copy first 4 bytes of BBytes into the last 4 */
- CopyBytes( BBytes, &BBytes[2], (Quad) 4);
- if(BBytes[0] != 6) return(19);
- if(BBytes[1] != 7) return(20);
- if(BBytes[2] != 6) return(21);
- if(BBytes[3] != 7) return(22);
- if(BBytes[4] != 8) return(23);
- if(BBytes[5] != 0) return(24);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExchangeBytes
- |
- | PURPOSE: To test the 'ExchangeBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast literal count parameters to be a 'Quad'
- | to avoid errors when using 'Think C'.
- |
- | ASSUMES:
- |
- | HISTORY: 11.10.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExchangeBytes()
- {
- Byte ABytes[] = { 1, 2, 3, 4 };
- Byte BBytes[] = { 5, 6, 7, 8 };
-
- ExchangeBytes( ABytes, BBytes, (Quad) 4 );
- if(BBytes[0] != 1) return(1);
- if(BBytes[1] != 2) return(2);
- if(BBytes[2] != 3) return(3);
- if(BBytes[3] != 4) return(4);
-
- if(ABytes[0] != 5) return(5);
- if(ABytes[1] != 6) return(6);
- if(ABytes[2] != 7) return(7);
- if(ABytes[3] != 8) return(8);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FillBytes
- |
- | PURPOSE: To test the 'FillBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast literal count parameter to be a 'Quad'
- | to avoid errors.
- |
- | ASSUMES:
- |
- | HISTORY: 11.10.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FillBytes()
- {
- Byte ABytes[] = { 0, 0, 0, 0 };
-
- FillBytes( &ABytes[1], (Quad) 2, (Pair) 1);
- if(ABytes[0] != 0) return(1);
- if(ABytes[1] != 1) return(2);
- if(ABytes[2] != 1) return(3);
- if(ABytes[3] != 0) return(4);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsMatchingBytes
- |
- | PURPOSE: To test the 'IsMatchingBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast literal count parameter to be a 'Quad'
- | to avoid errors.
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsMatchingBytes()
- {
- Truth Result;
- Byte ABytes[] = { 0, 0, 0, 0 };
- Byte BBytes[] = { 0, 1, 2, 3 };
-
- Result = IsMatchingBytes( ABytes, BBytes, (Quad) 4);
- if(Result != 0) return(1);
-
- Result = IsMatchingBytes( ABytes, ABytes, (Quad) 4);
- if(Result == 0) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ReplaceBytes
- |
- | PURPOSE: To test the 'ReplaceBytes' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: You must cast literal count parameter to be a 'Quad'
- | to avoid errors.
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ReplaceBytes()
- {
- Truth Result;
- Byte ABytes[] = { 4, 3, 6, 1 };
-
- ReplaceBytes( ABytes, (Quad) 4, (Pair) 3, (Pair) 9 );
- ReplaceBytes( ABytes, (Quad) 4, (Pair) 6, (Pair) 7 );
- if(ABytes[0] != 4) return(1);
- if(ABytes[1] != 9) return(2);
- if(ABytes[2] != 7) return(3);
- if(ABytes[3] != 1) return(4);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_AppendString
- |
- | PURPOSE: To test the 'AppendString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_AppendString()
- {
- Truth Result;
- String ABytes[] = "First\0 ";
- String BBytes[] = "Last";
-
- AppendString( ABytes, BBytes );
- if(ABytes[0] != 'F') return(1);
- if(ABytes[1] != 'i') return(2);
- if(ABytes[2] != 'r') return(3);
- if(ABytes[3] != 's') return(4);
- if(ABytes[4] != 't') return(5);
- if(ABytes[5] != 'L') return(6);
- if(ABytes[6] != 'a') return(7);
- if(ABytes[7] != 's') return(8);
- if(ABytes[8] != 't') return(9);
- if(ABytes[9] != 0 ) return(10);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_AppendStrings
- |
- | PURPOSE: To test the 'AppendStrings' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_AppendStrings()
- {
- Truth Result;
- String ABytes[] = "1st\0 ";
- String BBytes[] = "2nd";
- String CBytes[] = "3rd";
-
- AppendStrings( ABytes,
- BBytes,
- CBytes,
- (AddressOfString) 0 );
-
- if(ABytes[0] != '1') return(1);
- if(ABytes[1] != 's') return(2);
- if(ABytes[2] != 't') return(3);
- if(ABytes[3] != '2') return(4);
- if(ABytes[4] != 'n') return(5);
- if(ABytes[5] != 'd') return(6);
- if(ABytes[6] != '3') return(7);
- if(ABytes[7] != 'r') return(8);
- if(ABytes[8] != 'd') return(9);
- if(ABytes[9] != 0 ) return(10);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CountString
- |
- | PURPOSE: To test the 'CountString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CountString()
- {
- Quad Result;
- String ABytes[] = "First";
- String BBytes[] = "Last";
-
- Result = CountString( ABytes );
- if(Result != 5) return(1);
-
- Result = CountString( BBytes );
- if(Result != 4) return(2);
-
- Result = CountString( "First" );
- if(Result != 5) return(3);
-
- Result = CountString( "Last" );
- if(Result != 4) return(4);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CopyString
- |
- | PURPOSE: To test the 'CopyString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CopyString()
- {
- String AString[] = "abc";
- String BString[] = ".....";
-
- /* Copy AString into middle of BString */
- CopyString( AString, &BString[1] );
- if(BString[0] != '.') return(1);
- if(BString[1] != 'a') return(2);
- if(BString[2] != 'b') return(3);
- if(BString[3] != 'c') return(4);
- if(BString[4] != 0 ) return(5);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CompareStrings
- |
- | PURPOSE: To test the 'CompareStrings' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CompareStrings()
- {
- Comparison Result;
-
-
- Result = CompareStrings( "abc", "ABC" );
- if(Result != 0) return(1);
-
- Result = CompareStrings( "abc", "ACC" );
- if(Result >= 0) return(2);
-
- Result = CompareStrings( "abc", "ABCD" );
- if(Result >= 0) return(3);
-
- Result = CompareStrings( "ABCD", "abc" );
- if(Result < 0) return(4);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ConvertStringToLowerCase
- |
- | PURPOSE: To test the 'ConvertStringToLowerCase' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ConvertStringToLowerCase()
- {
- String AString[] = "123ABC";
-
- ConvertStringToLowerCase( AString );
- if(AString[0] != '1') return(1);
- if(AString[1] != '2') return(2);
- if(AString[2] != '3') return(3);
- if(AString[3] != 'a') return(4);
- if(AString[4] != 'b') return(5);
- if(AString[5] != 'c') return(6);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ConvertStringToUpperCase
- |
- | PURPOSE: To test the 'ConvertStringToUpperCase' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ConvertStringToUpperCase()
- {
- String AString[] = "123abc";
-
- ConvertStringToUpperCase( AString );
- if(AString[0] != '1') return(1);
- if(AString[1] != '2') return(2);
- if(AString[2] != '3') return(3);
- if(AString[3] != 'A') return(4);
- if(AString[4] != 'B') return(5);
- if(AString[5] != 'C') return(6);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindLastByteInString
- |
- | PURPOSE: To test the 'FindLastByteInString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindLastByteInString()
- {
- String AString[] = "123abc";
- String BString[] = "\0";
-
- AddressOfString LastByte;
-
- LastByte = FindLastByteInString( AString );
- if(LastByte != &AString[5]) return(1);
-
- LastByte = FindLastByteInString( BString );
- if(LastByte != &BString[-1]) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertString
- |
- | PURPOSE: To test the 'InsertString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertString()
- {
- String AString[] = "AA.\0 ";
- String BString[] = " is ";
-
- AddressOfString LastByte;
-
- InsertString( BString, AString, (Quad) 1 );
- if(AString[0] != 'A') return(1);
- if(AString[1] != ' ') return(2);
- if(AString[2] != 'i') return(3);
- if(AString[3] != 's') return(4);
- if(AString[4] != ' ') return(5);
- if(AString[5] != 'A') return(6);
- if(AString[6] != '.') return(7);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ReplaceByteInString
- |
- | PURPOSE: To test the 'ReplaceByteInString' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE: 'Pair' used as parameter instead of 'Byte' because
- | Think C can't pass 'Byte' parameters properly. See
- | 'DataSize.h' for more.
- |
- | ASSUMES:
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ReplaceByteInString()
- {
- Truth Result;
- String AString[] = "A is B.";
-
- ReplaceBytesInString( AString, (Pair) 'B', (Pair) 'A' );
- if(AString[0] != 'A') return(1);
- if(AString[1] != ' ') return(2);
- if(AString[2] != 'i') return(3);
- if(AString[3] != 's') return(4);
- if(AString[4] != ' ') return(5);
- if(AString[5] != 'A') return(6);
- if(AString[6] != '.') return(7);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetNextItem
- |
- | PURPOSE: To test the 'GetNextItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetNextItem()
- {
- AddressOfItem AnItem;
-
- AnItem = GetNextItem(TestItem);
-
- if(AnItem != (AddressOfItem) 2) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutNextItem
- |
- | PURPOSE: To test the 'PutNextItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutNextItem()
- {
- AddressOfItem AnItem;
-
- PutNextItem(TestItem,(AddressOfItem) 20);
- AnItem = GetNextItem(TestItem);
-
- if(AnItem != (AddressOfItem) 20) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheNextItem
- |
- | PURPOSE: To test the 'TheNextItem' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheNextItem()
- {
- AddressOfItem AnItem;
-
- TheItem = TestItem;
-
- if(TheNextItem != GetNextItem(TestItem)) return(1);
-
- TheNextItem = (AddressOfItem) 44;
- if(GetNextItem(TestItem) != (AddressOfItem) 44) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetPriorItem
- |
- | PURPOSE: To test the 'GetPriorItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetPriorItem()
- {
- AddressOfItem AnItem;
-
- AnItem = GetPriorItem(TestItem);
-
- if(AnItem != (AddressOfItem) 4) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutPriorItem
- |
- | PURPOSE: To test the 'PutPriorItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutPriorItem()
- {
- AddressOfItem AnItem;
-
- PutPriorItem(TestItem,(AddressOfItem) 22);
- AnItem = GetPriorItem(TestItem);
-
- if(AnItem != (AddressOfItem) 22) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ThePriorItem
- |
- | PURPOSE: To test the 'ThePriorItem' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ThePriorItem()
- {
- AddressOfItem AnItem;
-
- TheItem = TestItem;
-
- if(ThePriorItem != GetPriorItem(TestItem)) return(1);
-
- ThePriorItem = (AddressOfItem) 46;
- if(GetPriorItem(TestItem) != (AddressOfItem) 46) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetItemDataAddress
- |
- | PURPOSE: To test the 'GetItemDataAddress' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetItemDataAddress()
- {
- AddressOfByte SomeData;
-
- SomeData = GetItemDataAddress(TestItem);
-
- if(SomeData != (AddressOfByte) 6) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutItemDataAddress
- |
- | PURPOSE: To test the 'PutItemDataAddress' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutItemDataAddress()
- {
- AddressOfByte SomeData;
-
- PutItemDataAddress(TestItem,(AddressOfByte) 24);
- SomeData = GetItemDataAddress(TestItem);
-
- if(SomeData != (AddressOfByte) 24) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheDataAddress
- |
- | PURPOSE: To test the 'TheDataAddress' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheDataAddress()
- {
- TheItem = TestItem;
-
- if(TheDataAddress != GetItemDataAddress(TestItem))
- return(1);
-
- TheDataAddress = (AddressOfByte) 33;
- if(GetItemDataAddress(TestItem) != (AddressOfByte) 33)
- return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetItemMark
- |
- | PURPOSE: To test the 'GetItemMark' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetItemMark()
- {
- Pair AMark;
-
- AMark = GetItemMark(TestItem);
-
- if(AMark != (Pair) 8) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutItemMark
- |
- | PURPOSE: To test the 'PutItemMark' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutItemMark()
- {
- Pair AMark;
-
- PutItemMark(TestItem,(Pair) 13);
- AMark = GetItemMark(TestItem);
-
- if(AMark != (Pair) 13) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheItemMark
- |
- | PURPOSE: To test the 'TheItemMark' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheItemMark()
- {
- TheItem = TestItem;
-
- if(TheItemMark != GetItemMark(TestItem)) return(1);
-
- TheItemMark = (Pair) Marked;
- if(GetItemMark(TestItem) != (Pair) Marked) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetFirstItemOfList
- |
- | PURPOSE: To test the 'GetFirstItemOfList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetFirstItemOfList()
- {
- AddressOfItem AnItem;
-
- AnItem = GetFirstItemOfList(TestList);
-
- if(AnItem != (AddressOfItem) 10) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutFirstItemOfList
- |
- | PURPOSE: To test the 'PutFirstItemOfList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutFirstItemOfList()
- {
- AddressOfItem AnItem;
-
- PutFirstItemOfList(TestList,(AddressOfItem) 24);
-
- AnItem = GetFirstItemOfList(TestList);
-
- if(AnItem != (AddressOfItem) 24) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheFirstItem
- |
- | PURPOSE: To test the 'TheFirstItem' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheFirstItem()
- {
- TheList = TestList;
-
- if(TheFirstItem != GetFirstItemOfList(TestList))
- return(1);
-
- TheFirstItem = (AddressOfItem) 888;
- if(GetFirstItemOfList(TestList) !=
- (AddressOfItem) 888) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetLastItemOfList
- |
- | PURPOSE: To test the 'GetLastItemOfList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetLastItemOfList()
- {
- AddressOfItem AnItem;
-
- AnItem = GetLastItemOfList(TestList);
-
- if(AnItem != (AddressOfItem) 12) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutLastItemOfList
- |
- | PURPOSE: To test the 'PutLastItemOfList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutLastItemOfList()
- {
- AddressOfItem AnItem;
-
- PutLastItemOfList(TestList,(AddressOfItem) 26);
-
- AnItem = GetLastItemOfList(TestList);
-
- if(AnItem != (AddressOfItem) 26) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheLastItem
- |
- | PURPOSE: To test the 'TheLastItem' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheLastItem()
- {
- TheList = TestList;
-
- if(TheLastItem != GetLastItemOfList(TestList))
- return(1);
-
- TheLastItem = (AddressOfItem) 890;
- if(GetLastItemOfList(TestList) !=
- (AddressOfItem) 890) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetListItemCount
- |
- | PURPOSE: To test the 'GetListItemCount' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetListItemCount()
- {
- Quad ACount;
-
- ACount = GetListItemCount(TestList);
-
- if(ACount != (Quad) 14) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutListItemCount
- |
- | PURPOSE: To test the 'PutListItemCount' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutListItemCount()
- {
- Quad ACount;
-
- PutListItemCount(TestList,(Quad) 17);
-
- ACount = GetListItemCount(TestList);
-
- if(ACount != (Quad) 17) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheItemCount
- |
- | PURPOSE: To test the 'TheItemCount' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheItemCount()
- {
- TheList = TestList;
-
- if(TheItemCount != GetListItemCount(TestList))
- return(1);
-
- TheItemCount = (Quad) 123;
- if(GetListItemCount(TestList) != (Quad) 123)
- return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_GetListMark
- |
- | PURPOSE: To test the 'GetListMark' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: A specific order of fields within an ItemRecord.
- |
- | HISTORY: 11.11.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_GetListMark()
- {
- Pair AMark;
-
- AMark = GetListMark(TestList);
-
- if(AMark != (Pair) 16) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PutListMark
- |
- | PURPOSE: To test the 'PutListMark' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PutListMark()
- {
- Pair AMark;
-
- PutListMark(TestList,(Pair) 19);
-
- AMark = GetListMark(TestList);
-
- if(AMark != (Pair) 19) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_TheListMark
- |
- | PURPOSE: To test the 'TheListMark' reference macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_TheListMark()
- {
- TheList = TestList;
-
- if(TheListMark != GetListMark(TestList))
- return(1);
-
- TheListMark = (Pair) Marked;
- if(GetListMark(TestList) != (Pair) Marked)
- return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_MarkItem
- |
- | PURPOSE: To test the 'MarkItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_MarkItem()
- {
- Pair AMark;
-
- PutItemMark(TestItem, (Pair) 0);
-
- MarkItem(TestItem);
-
- AMark = GetItemMark(TestItem);
-
- if(AMark != (Pair) Marked) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_UnMarkItem
- |
- | PURPOSE: To test the 'UnMarkItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_UnMarkItem()
- {
- Pair AMark;
-
- PutItemMark(TestItem, (Pair) Marked);
-
- UnMarkItem(TestItem);
-
- AMark = GetItemMark(TestItem);
-
- if(AMark == (Pair) Marked) return(1);
-
- return(False);
- }
-
-
- /*------------------------------------------------------------
- | NAME: Test_IsItemMarked
- |
- | PURPOSE: To test the 'IsItemMarked' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsItemMarked()
- {
- Pair AMark;
-
- MarkItem(TestItem);
-
- if(!IsItemMarked(TestItem)) return(1);
-
- UnMarkItem(TestItem);
-
- if(IsItemMarked(TestItem)) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_MarkList
- |
- | PURPOSE: To test the 'MarkList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_MarkList()
- {
- Pair AMark;
-
- PutListMark(TestList, (Pair) 0);
-
- MarkList(TestList);
-
- AMark = GetListMark(TestList);
-
- if(AMark != (Pair) Marked) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_UnMarkList
- |
- | PURPOSE: To test the 'UnMarkList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_UnMarkList()
- {
- Pair AMark;
-
- PutListMark(TestList, (Pair) Marked);
-
- UnMarkList(TestList);
-
- AMark = GetListMark(TestList);
-
- if(AMark == (Pair) Marked) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsListMarked
- |
- | PURPOSE: To test the 'IsListMarked' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsListMarked()
- {
- Pair AMark;
-
- MarkList(TestList);
-
- if(!IsListMarked(TestList)) return(1);
-
- UnMarkList(TestList);
-
- if(IsListMarked(TestList)) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_MarkItemAsFirst
- |
- | PURPOSE: To test the 'MarkItemAsFirst' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_MarkItemAsFirst()
- {
- PutPriorItem(TestItem,(AddressOfItem) 1900);
-
- MarkItemAsFirst(TestItem);
-
- if(GetPriorItem(TestItem) != (AddressOfItem) 0)
- return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsItemFirst
- |
- | PURPOSE: To test the 'IsItemFirst' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsItemFirst()
- {
-
- MarkItemAsFirst(TestItem);
-
- if(!IsItemFirst(TestItem)) return(1);
-
- PutPriorItem(TestItem,(AddressOfItem) 1900);
- if(IsItemFirst(TestItem)) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_MarkItemAsFirst
- |
- | PURPOSE: To test the 'MarkItemAsFirst' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_MarkItemAsLast()
- {
- PutNextItem(TestItem,(AddressOfItem) 1904);
-
- MarkItemAsLast(TestItem);
-
- if(GetNextItem(TestItem) != (AddressOfItem) 0)
- return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsItemLast
- |
- | PURPOSE: To test the 'IsItemLast' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsItemLast()
- {
-
- MarkItemAsLast(TestItem);
-
- if(!IsItemLast(TestItem)) return(1);
-
- PutNextItem(TestItem,(AddressOfItem) 1902);
- if(IsItemLast(TestItem)) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsItemAlone
- |
- | PURPOSE: To test the 'IsItemAlone' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsItemAlone()
- {
-
- PutNextItem(TestItem,(AddressOfItem) 1906);
- if(IsItemAlone(TestItem)) return(1);
-
- MarkItemAsLast(TestItem);
-
- PutPriorItem(TestItem,(AddressOfItem) 1908);
- if(IsItemAlone(TestItem)) return(2);
-
- MarkItemAsFirst(TestItem);
- if(!IsItemAlone(TestItem)) return(3);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ToNextItem
- |
- | PURPOSE: To test the 'ToNextItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ToNextItem()
- {
-
- TheItem = TestItem;
-
- PutNextItem(TestItem,(AddressOfItem) 1908);
-
- ToNextItem();
- if(TheItem != (AddressOfItem) 1908) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ToPriorItem
- |
- | PURPOSE: To test the 'ToPriorItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ToPriorItem()
- {
-
- TheItem = TestItem;
-
- PutPriorItem(TestItem,(AddressOfItem) 1910);
-
- ToPriorItem();
- if(TheItem != (AddressOfItem) 1910) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ToFirstItem
- |
- | PURPOSE: To test the 'ToFirstItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ToFirstItem()
- {
-
- TheList = TestList;
-
- TheFirstItem = TestItem;
- TheLastItem = (AddressOfItem) 0;
-
- TheItem = (AddressOfItem) 1912;
-
- ToFirstItem();
- if(TheItem != TestItem) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ToLastItem
- |
- | PURPOSE: To test the 'ToLastItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ToLastItem()
- {
-
- TheList = TestList;
-
- TheLastItem = TestItem;
- TheFirstItem = (AddressOfItem) 0;
-
- TheItem = (AddressOfItem) 1914;
-
- ToLastItem();
- if(TheItem != TestItem) return(1);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SetUpTheListSystem
- |
- | PURPOSE: To test the 'SetUpTheListSystem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SetUpTheListSystem()
- {
- TheListSystemIsSetUp = False;
-
- TheListStackIndex = 10;
- MaxCountOfLists = 0;
- MaxCountOfItems = 0;
- ListSpace = 0;
- ItemSpace = 0;
- CountOfFreeItems = 0;
- CountOfFreeLists = 0;
- FirstFreeList = 0;
- FirstFreeItem = 0;
-
- SetUpTheListSystem((Quad) 30, (Quad) 100);
-
- if( TheListSystemIsSetUp == False ) return(1);
- if( TheListStackIndex != 0 ) return(2);
- if( MaxCountOfLists != 30 ) return(3);
- if( MaxCountOfItems != 100 ) return(4);
- if( ListSpace == 0 ) return(5);
- if( ItemSpace == 0 ) return(6);
- if( CountOfFreeItems != 100 ) return(7);
- if( CountOfFreeLists != 30 ) return(8);
- if( FirstFreeList != ListSpace ) return(9);
- if( FirstFreeItem != ItemSpace ) return(10);
-
- TheList = FirstFreeList;
- if(TheFirstItem != (AddressOfItem) &ListSpace[1] )
- return(11);
-
- TheItem = FirstFreeItem;
- if(TheNextItem != (AddressOfItem) &ItemSpace[1] )
- return(12);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PushTheItem
- |
- | PURPOSE: To test the 'PushTheItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PushTheItem()
- {
- Quad i;
-
- TheItem = TestItem;
- i = TheListStackIndex;
-
- PushTheItem();
-
- if(TheListStackIndex != i+1) return(1);
- if(TheListStack[i+1] != (Quad) TestItem) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PullTheItem
- |
- | PURPOSE: To test the 'PullTheItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PullTheItem()
- {
- Quad i;
-
- TheItem = TestItem;
- i = TheListStackIndex;
-
- PushTheItem();
- TheItem = (AddressOfItem) 0;
- PullTheItem();
-
- if(TheListStackIndex != i) return(1);
- if(TheItem != TestItem) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PushTheList
- |
- | PURPOSE: To test the 'PushTheList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PushTheList()
- {
- Quad i;
-
- TheList = TestList;
- i = TheListStackIndex;
-
- PushTheList();
-
- if(TheListStackIndex != i+1) return(1);
- if(TheListStack[i+1] != (Quad) TestList) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PullTheList
- |
- | PURPOSE: To test the 'PullTheList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PullTheList()
- {
- Quad i;
-
- TheList = TestList;
- i = TheListStackIndex;
-
- PushTheList();
- TheList = (AddressOfList) 0;
- PullTheList();
-
- if(TheListStackIndex != i) return(1);
- if(TheList != TestList) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PushTheListAndItem
- |
- | PURPOSE: To test the 'PushTheListAndItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PushTheListAndItem()
- {
- Quad i;
-
- TheList = TestList;
- TheItem = TestItem;
-
- i = TheListStackIndex;
-
- PushTheListAndItem();
-
- if(TheListStackIndex != i+2) return(1);
- if(TheListStack[i+1] != (Quad) TestList) return(2);
- if(TheListStack[i+2] != (Quad) TestItem) return(3);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_PullTheListAndItem
- |
- | PURPOSE: To test the 'PullTheListAndItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_PullTheListAndItem()
- {
- Quad i;
-
- TheList = TestList;
- TheItem = TestItem;
-
- i = TheListStackIndex;
-
- PushTheListAndItem();
-
- TheList = (AddressOfList) 0;
- TheItem = (AddressOfItem) 0;
-
- PullTheListAndItem();
-
- if(TheListStackIndex != i) return(1);
- if(TheList != TestList) return(2);
- if(TheItem != TestItem) return(3);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_MarkListAsEmpty
- |
- | PURPOSE: To test the 'MarkListAsEmpty' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_MarkListAsEmpty()
- {
-
- TheList = TestList;
-
- TheFirstItem = TestItem;
- TheLastItem = TestItem;
- TheItemCount = (Quad) 1;
-
- MarkListAsEmpty(TestList);
-
- if(TheItemCount != (Quad) 0) return(1);
- if(TheFirstItem != (AddressOfItem) 0) return(2);
- if(TheLastItem != (AddressOfItem) 0) return(3);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsAnyItemsInList
- |
- | PURPOSE: To test the 'IsAnyItemsInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsAnyItemsInList()
- {
-
- TheList = TestList;
-
- TheFirstItem = TestItem;
- TheLastItem = TestItem;
- TheItemCount = (Quad) 1;
- if(!IsAnyItemsInList(TheList)) return(1);
-
- MarkListAsEmpty(TestList);
- if(IsAnyItemsInList(TheList)) return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsItemCreationPossible
- |
- | PURPOSE: To test the 'IsItemCreationPossible' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsItemCreationPossible()
- {
- Quad Temp;
-
- Temp = CountOfFreeItems;
-
- CountOfFreeItems = (Quad) 1;
- if(!IsItemCreationPossible()) return(1);
-
- CountOfFreeItems = (Quad) 0;
- if(IsItemCreationPossible()) return(2);
-
- CountOfFreeItems = Temp;
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsListCreationPossible
- |
- | PURPOSE: To test the 'IsListCreationPossible' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.16.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsListCreationPossible()
- {
- Quad Temp;
-
- Temp = CountOfFreeLists;
-
- CountOfFreeLists = (Quad) 1;
- if(!IsListCreationPossible()) return(1);
-
- CountOfFreeLists = (Quad) 0;
- if(IsListCreationPossible()) return(2);
-
- CountOfFreeLists = Temp;
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CreateItem
- |
- | PURPOSE: To test the 'CreateItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CreateItem()
- {
- AddressOfItem AnItem;
- Quad CountBefore;
- AddressOfItem SecondFreeItem;
-
- CountBefore = CountOfFreeItems;
- SecondFreeItem = GetNextItem(FirstFreeItem);
-
- AnItem = CreateItem();
-
- if(CountOfFreeItems < 0) return(1);
- if(CountOfFreeItems != CountBefore - 1) return(2);
- if(FirstFreeItem != SecondFreeItem) return(3);
- if(IsItemMarked(AnItem)) return(4);
-
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteItem(AnItem);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteItem
- |
- | PURPOSE: To test the 'DeleteItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteItem()
- {
- AddressOfItem AnItem;
- Quad CountBefore;
- AddressOfItem FreeItemBefore;
-
- AnItem = CreateItem();
-
- CountBefore = CountOfFreeItems;
- FreeItemBefore = FirstFreeItem;
-
- DeleteItem(AnItem);
-
- if(CountOfFreeItems <= 0) return(1);
- if(CountOfFreeItems != CountBefore + 1) return(2);
- if(GetNextItem(FirstFreeItem) != FreeItemBefore)
- return(3);
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CreateItemForData
- |
- | PURPOSE: To test the 'CreateItemForData' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CreateItemForData()
- {
- Byte SomeData[] = "A is A.";
- AddressOfItem AnItem;
-
- AnItem = CreateItemForData(SomeData);
-
- if(GetItemDataAddress(AnItem) != SomeData) return(1);
-
- DeleteItem(AnItem);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CreateList
- |
- | PURPOSE: To test the 'CreateList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CreateList()
- {
- AddressOfList AList;
- Quad CountBefore;
- AddressOfList SecondFreeList;
-
- CountBefore = CountOfFreeLists;
- SecondFreeList = (AddressOfList)
- GetFirstItemOfList(FirstFreeList);
-
- AList = CreateList();
-
- if(CountOfFreeLists < 0) return(1);
- if(CountOfFreeLists != CountBefore - 1) return(2);
- if(FirstFreeList != SecondFreeList) return(3);
- if(IsListMarked(AList)) return(4);
- if(IsAnyItemsInList(AList)) return(5);
-
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteList(AList);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_AddToListItemCount
- |
- | PURPOSE: To test the 'AddToListItemCount' macro.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_AddToListItemCount()
- {
- Quad CountBefore;
- AddressOfItem AnItem;
-
- PushTheListAndItem();
-
- TheList = TestList;
-
- TheItemCount = 0;
-
- AddToListItemCount( TheList, 1);
- if(TheItemCount != (Quad) 1) return(1);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertItemLastInList
- |
- | PURPOSE: To test the 'InsertItemLastInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertItemLastInList()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "Existence is identity.";
- FirstItem = CreateItemForData(SomeData);
- InsertItemLastInList(TheList,FirstItem);
-
- if(TheItemCount != 1) return(1);
- if(TheFirstItem != FirstItem) return(2);
- if(TheLastItem != FirstItem) return(3);
-
- SomeData = (AddressOfByte) "Consciousness is identification.";
- SecondItem = CreateItemForData(SomeData);
- InsertItemLastInList(TheList,SecondItem);
-
- if(TheItemCount != 2) return(4);
- if(TheLastItem != SecondItem) return(5);
- if(TheFirstItem != FirstItem) return(6);
- if(GetNextItem(FirstItem) != SecondItem) return(7);
- if(GetPriorItem(SecondItem) != FirstItem) return(8);
-
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertDataLastInList
- |
- | PURPOSE: To test the 'InsertDataLastInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertDataLastInList()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "Existence is identity.";
- FirstItem = InsertDataLastInList(TheList,SomeData);
-
- TheItem = FirstItem;
- if(TheDataAddress != SomeData) return(1);
-
- SomeData = (AddressOfByte)
- "Consciousness is identification.";
- SecondItem = InsertDataLastInList(TheList,SomeData);
-
- TheItem = SecondItem;
- if(TheDataAddress != SomeData) return(2);
-
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExtractTheItem
- |
- | PURPOSE: To test the 'ExtractTheItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExtractTheItem()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfItem ThirdItem;
- AddressOfItem ExtractedItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "aaa";
- FirstItem = InsertDataLastInList(TheList,SomeData);
-
- SomeData = (AddressOfByte) "bbb";
- SecondItem = InsertDataLastInList(TheList,SomeData);
-
- SomeData = (AddressOfByte) "ccc";
- ThirdItem = InsertDataLastInList(TheList,SomeData);
-
- /* CASE: extracting last item */
- TheItem = ThirdItem;
- ExtractedItem = ExtractTheItem();
- if(ExtractedItem != ThirdItem) return(1);
- if(TheItemCount != 2) return(2);
- if(TheItem != SecondItem) return(3);
- if(GetNextItem(FirstItem) != SecondItem) return(4);
- if(GetPriorItem(SecondItem) != FirstItem) return(5);
- if(TheFirstItem != FirstItem) return(6);
- if(TheLastItem != SecondItem) return(7);
-
- InsertItemLastInList(TheList,ExtractedItem); /* put back the item */
-
- /* CASE: extracting middle item */
- TheItem = SecondItem;
- ExtractedItem = ExtractTheItem();
-
- if(ExtractedItem != SecondItem) return(8);
- if(TheItemCount != 2) return(9);
- if(TheItem != FirstItem) return(10);
- if(GetNextItem(FirstItem) != ThirdItem) return(11);
- if(GetPriorItem(ThirdItem) != FirstItem) return(12);
- if(TheFirstItem != FirstItem) return(13);
- if(TheLastItem != ThirdItem) return(14);
-
- DeleteItem(ExtractedItem);
-
- /* CASE: extracting first item */
- TheItem = FirstItem;
- ExtractedItem = ExtractTheItem();
-
- if(ExtractedItem != FirstItem) return(15);
- if(TheItemCount != 1) return(16);
- if(TheItem != ThirdItem) return(17);
- if(!IsItemAlone(ThirdItem)) return(18);
- if(TheFirstItem != ThirdItem) return(19);
- if(TheLastItem != ThirdItem) return(20);
-
- DeleteItem(ExtractedItem);
-
- /* CASE: extracting lone item */
- ExtractedItem = ExtractTheItem();
-
- if(ExtractedItem != ThirdItem) return(21);
- if(TheItemCount != 0) return(22);
- if(TheItem != (AddressOfItem) 0) return(23);
- if(TheFirstItem != (AddressOfItem) 0) return(24);
- if(TheLastItem != (AddressOfItem) 0) return(25);
- DeleteItem(ExtractedItem);
-
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExtractItemFromList
- |
- | PURPOSE: To test the 'ExtractItemFromList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExtractItemFromList()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfItem ThirdItem;
- AddressOfItem ExtractedItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "aaa";
- FirstItem = InsertDataLastInList(TheList,SomeData);
-
- SomeData = (AddressOfByte) "bbb";
- SecondItem = InsertDataLastInList(TheList,SomeData);
-
- SomeData = (AddressOfByte) "ccc";
- ThirdItem = InsertDataLastInList(TheList,SomeData);
-
- /* CASE: extracting last item */
- ToFirstItem();
- ExtractedItem = ExtractItemFromList(TheList,ThirdItem);
- if(ExtractedItem != ThirdItem) return(1);
- if(TheItemCount != 2) return(2);
- if(TheItem != FirstItem) return(3);
- if(GetNextItem(FirstItem) != SecondItem) return(4);
- if(GetPriorItem(SecondItem) != FirstItem) return(5);
- if(TheFirstItem != FirstItem) return(6);
- if(TheLastItem != SecondItem) return(7);
-
- InsertItemLastInList(TheList,ExtractedItem); /* put back the item */
-
- /* CASE: extracting middle item */
- ToLastItem();
- ExtractedItem = ExtractItemFromList(TheList,SecondItem);
-
- if(ExtractedItem != SecondItem) return(8);
- if(TheItemCount != 2) return(9);
- if(TheItem != ThirdItem) return(10);
- if(GetNextItem(FirstItem) != ThirdItem) return(11);
- if(GetPriorItem(ThirdItem) != FirstItem) return(12);
- if(TheFirstItem != FirstItem) return(13);
- if(TheLastItem != ThirdItem) return(14);
- DeleteItem(ExtractedItem);
-
- /* CASE: extracting first item */
-
- ExtractedItem = ExtractItemFromList(TheList,FirstItem);
-
- if(ExtractedItem != FirstItem) return(15);
- if(TheItemCount != 1) return(16);
- if(TheItem != ThirdItem) return(17);
- if(!IsItemAlone(ThirdItem)) return(18);
- if(TheFirstItem != ThirdItem) return(19);
- if(TheLastItem != ThirdItem) return(20);
- DeleteItem(ExtractedItem);
-
- /* CASE: extracting lone item */
- ExtractedItem = ExtractItemFromList(TheList,ThirdItem);
-
- if(ExtractedItem != ThirdItem) return(21);
- if(TheItemCount != 0) return(22);
- if(TheItem != ThirdItem) return(23);
- if(TheFirstItem != (AddressOfItem) 0) return(24);
- if(TheLastItem != (AddressOfItem) 0) return(25);
- DeleteItem(ExtractedItem);
- /*
- The following procedure is not validated at this
- point in the test sequence so it can't be used
- to establish the validity of the procedure being
- tested. It's only to clean up after the test.
- */
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteList
- |
- | PURPOSE: To test the 'DeleteList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.17.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteList()
- {
- Quad ItemCountBefore;
- Quad ListCountBefore;
- AddressOfList FreeListBefore;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- InsertDataLastInList(TheList,(AddressOfByte) "aaa");
- InsertDataLastInList(TheList,(AddressOfByte) "bbb");
- InsertDataLastInList(TheList,(AddressOfByte) "ccc");
-
- ItemCountBefore = CountOfFreeItems;
- ListCountBefore = CountOfFreeLists;
- FreeListBefore = FirstFreeList;
-
- DeleteList(TheList);
-
- if(CountOfFreeItems != ItemCountBefore + (Quad) 3) return(1);
- if(CountOfFreeLists != ListCountBefore + (Quad) 1) return(2);
- if(FirstFreeList != TheList) return(3);
- if((AddressOfList)
- GetFirstItemOfList(FirstFreeList) !=
- FreeListBefore) return(4);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: MakeSampleListOfStaticStrings
- |
- | PURPOSE: To make a list of strings allocated at compile time
- | to be used for testing other procedures.
- |
- | DESCRIPTION: Returns the list record address of a list
- | which looks like this:
- |
- | [LIST]--->[ITEM]--->"AAAA"
- | [ITEM]--->"BBBB"
- | [ITEM]--->"CCCC"
- |
- | EXAMPLE: AList = MakeSampleListOfStaticStrings();
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Byte AData[] = "AAAA";
- Byte BData[] = "BBBB";
- Byte CData[] = "CCCC";
- AddressOfList
- MakeSampleListOfStaticStrings()
- {
- AddressOfList AList;
- AddressOfByte SomeData;
-
- AList = CreateList();
-
- InsertDataLastInList(AList,AData);
- InsertDataLastInList(AList,BData);
- InsertDataLastInList(AList,CData);
-
- return(AList);
- }
-
- /*------------------------------------------------------------
- | NAME: MakeSampleListOfDynamicStrings
- |
- | PURPOSE: To make a list of dynamically allocated strings
- | to be used for testing other procedures.
- |
- | DESCRIPTION: Returns the list record address of a list
- | which looks like this:
- |
- | [LIST]--->[ITEM]--->"AAAA"
- | [ITEM]--->"BBBB"
- | [ITEM]--->"CCCC"
- |
- | EXAMPLE: AList = MakeSampleListOfDynamicStrings();
- |
- | NOTE:
- |
- | ASSUMES: 'AllocateMemory' is valid.
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- AddressOfList
- MakeSampleListOfDynamicStrings()
- {
- AddressOfList AList;
- AddressOfByte SomeData;
-
- AList = CreateList();
-
- SomeData = AllocateMemory(5);
- CopyString("AAAA",(AddressOfString) SomeData);
- InsertDataLastInList(AList,SomeData);
-
- SomeData = AllocateMemory(5);
- CopyString("BBBB",(AddressOfString) SomeData);
- InsertDataLastInList(AList,SomeData);
-
- SomeData = AllocateMemory(5);
- CopyString("CCCC",(AddressOfString) SomeData);
- InsertDataLastInList(AList,SomeData);
-
- return(AList);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteListOfDynamicData
- |
- | PURPOSE: To test the 'DeleteListOfDynamicData' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: 'AllocateMemory' and 'FreeMemory' are valid.
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteListOfDynamicData()
- {
- Quad ItemCountBefore;
- Quad ListCountBefore;
- AddressOfList AList;
-
- AList = MakeSampleListOfDynamicStrings();
-
- ItemCountBefore = CountOfFreeItems;
- ListCountBefore = CountOfFreeLists;
-
- DeleteListOfDynamicData(AList);
- if(ItemCountBefore != CountOfFreeItems - (Quad) 3)
- return(1);
- if(ListCountBefore != CountOfFreeLists - (Quad) 1)
- return(2);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindFirstItemLinkedToData
- |
- | PURPOSE: To test the 'FindFirstItemLinkedToData' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindFirstItemLinkedToData()
- {
- AddressOfByte FirstData;
- AddressOfByte MiddleData;
- AddressOfByte LastData;
- AddressOfItem AnItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfDynamicStrings();
-
- FirstData = GetItemDataAddress(TheFirstItem);
- MiddleData = GetItemDataAddress(GetNextItem(TheFirstItem));
- LastData = GetItemDataAddress(TheLastItem);
-
- AnItem = FindFirstItemLinkedToData(TheList,FirstData);
- if(AnItem != TheFirstItem) return(1);
-
- AnItem = FindFirstItemLinkedToData(TheList,MiddleData);
- if(AnItem != GetNextItem(TheFirstItem)) return(2);
-
- AnItem = FindFirstItemLinkedToData(TheList,LastData);
- if(AnItem != TheLastItem) return(3);
-
- DeleteListOfDynamicData(TheList);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteFirstReferenceToData
- |
- | PURPOSE: To test the 'DeleteFirstReferenceToData' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteFirstReferenceToData()
- {
- AddressOfItem AnItem;
- AddressOfItem FirstItem;
- AddressOfItem MiddleItem;
- AddressOfItem LastItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- FirstItem = TheFirstItem;
- MiddleItem = GetNextItem(TheFirstItem);
- LastItem = TheLastItem;
-
- AnItem = DeleteFirstReferenceToData(TheList,(AddressOfByte) 1);
- if(AnItem) return(1);
- if(TheItemCount != (Quad) 3) return(2);
-
- AnItem = DeleteFirstReferenceToData(TheList,BData);
- if(AnItem != MiddleItem) return(3);
-
- AnItem = DeleteFirstReferenceToData(TheList,AData);
- if(AnItem != FirstItem) return(4);
-
- AnItem = DeleteFirstReferenceToData(TheList,CData);
- if(AnItem != LastItem) return(5);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteAllReferencesToData
- |
- | PURPOSE: To test the 'DeleteAllReferencesToData' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteAllReferencesToData()
- {
- AddressOfItem AnItem;
- AddressOfItem FirstItem;
- AddressOfItem MiddleItem;
- AddressOfItem LastItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- FirstItem = TheFirstItem;
- MiddleItem = GetNextItem(TheFirstItem);
- LastItem = TheLastItem;
-
- PutItemDataAddress( TheLastItem, BData );
-
- DeleteAllReferencesToData( TheList, (AddressOfByte) 1 );
- if(TheItemCount != (Quad) 3) return(1);
-
- DeleteAllReferencesToData( TheList, BData );
- if(TheItemCount != (Quad) 1) return(2);
- if(TheFirstItem != FirstItem) return(3);
- if(TheLastItem != FirstItem) return(4);
-
- DeleteAllReferencesToData( TheList, AData );
- if(TheItemCount != (Quad) 0) return(5);
- if(TheFirstItem != (AddressOfItem) 0) return(6);
- if(TheLastItem != (AddressOfItem) 0) return(7);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsTheDataMatching
- |
- | PURPOSE: To test the 'IsTheDataMatching' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsTheDataMatching()
- {
- Truth Result;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- ToFirstItem();
- Result = IsTheDataMatching( (Pair) 0, (Pair) 4, AData );
- if(Result == 0) return(1);
-
-
- ToNextItem();
- Result = IsTheDataMatching( (Pair) 0, (Pair) 4, BData );
- if(Result == 0) return(2);
-
-
- ToNextItem();
- Result = IsTheDataMatching( (Pair) 0, (Pair) 4, CData );
- if(Result == 0) return(3);
-
- Result = IsTheDataMatching( (Pair) 0, (Pair) 4, BData );
- if(Result != 0) return(4);
-
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindFirstMatchingItem
- |
- | PURPOSE: To test the 'FindFirstMatchingItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindFirstMatchingItem()
- {
- Truth Result;
- AddressOfItem AnItem;
- Pair SearchKeyFieldOffset;
- Pair SearchKeyFieldWidth;
- AddressOfByte SearchValue;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- SearchValue = (AddressOfByte) "XXXX";
- SearchKeyFieldOffset = 0;
- SearchKeyFieldWidth = 4;
-
- AnItem = FindFirstMatchingItem( TheList,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != (AddressOfItem) 0) return(1);
-
- SearchValue = (AddressOfByte) "AAAA";
- AnItem = FindFirstMatchingItem( TheList,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != TheFirstItem) return(2);
-
- SearchValue = (AddressOfByte) "BBBB";
- AnItem = FindFirstMatchingItem( TheList,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != GetNextItem(TheFirstItem)) return(3);
-
- SearchValue = (AddressOfByte) "CCCC";
- AnItem = FindFirstMatchingItem( TheList,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != TheLastItem) return(3);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindNextMatchingItem
- |
- | PURPOSE: To test the 'FindNextMatchingItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.18.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindNextMatchingItem()
- {
- Truth Result;
- AddressOfItem AnItem;
- Pair SearchKeyFieldOffset;
- Pair SearchKeyFieldWidth;
- AddressOfByte SearchValue;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- SearchValue = (AddressOfByte) "XXXX";
- SearchKeyFieldOffset = 0;
- SearchKeyFieldWidth = 4;
-
- AnItem = FindNextMatchingItem( TheList,
- TheFirstItem,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != (AddressOfItem) 0) return(1);
-
- SearchValue = (AddressOfByte) "AAAA";
- AnItem = FindNextMatchingItem( TheList,
- TheFirstItem,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem == TheFirstItem) return(2);
-
- SearchValue = (AddressOfByte) "BBBB";
- AnItem = FindNextMatchingItem( TheList,
- TheFirstItem,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != GetNextItem(TheFirstItem)) return(3);
-
- SearchValue = (AddressOfByte) "CCCC";
- AnItem = FindNextMatchingItem( TheList,
- TheFirstItem,
- SearchKeyFieldOffset,
- SearchKeyFieldWidth,
- SearchValue );
-
- if(AnItem != TheLastItem) return(3);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindFirstMarkedItem
- |
- | PURPOSE: To test the 'FindFirstMarkedItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindFirstMarkedItem()
- {
- Truth Result;
- AddressOfItem AnItem;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- AnItem = FindFirstMarkedItem( TheList );
-
- if(AnItem != (AddressOfItem) 0 ) return(1);
-
- MarkItem( TheLastItem );
-
- AnItem = FindFirstMarkedItem( TheList );
-
- if(AnItem != TheLastItem ) return(2);
-
- MarkItem( GetPriorItem(TheLastItem) );
-
- AnItem = FindFirstMarkedItem( TheList );
-
- if(AnItem != GetPriorItem(TheLastItem) ) return(3);
-
- MarkItem( TheFirstItem );
-
- AnItem = FindFirstMarkedItem( TheList );
-
- if(AnItem != TheFirstItem ) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindFirstUnMarkedItem
- |
- | PURPOSE: To test the 'FindFirstUnMarkedItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindFirstUnMarkedItem()
- {
- Truth Result;
- AddressOfItem AnItem;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- AnItem = FindFirstUnMarkedItem( TheList );
- if(AnItem != TheFirstItem ) return(1);
-
- MarkItem( TheFirstItem );
- AnItem = FindFirstUnMarkedItem( TheList );
- if(AnItem != GetNextItem(TheFirstItem) ) return(2);
-
- MarkItem( GetNextItem(TheFirstItem) );
- AnItem = FindFirstUnMarkedItem( TheList );
- if(AnItem != TheLastItem ) return(3);
-
- MarkItem( TheLastItem );
- AnItem = FindFirstUnMarkedItem( TheList );
-
- if(AnItem != (AddressOfItem) 0 ) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_UnMarkAllItemsInList
- |
- | PURPOSE: To test the 'UnMarkAllItemsInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_UnMarkAllItemsInList()
- {
- Truth Result;
- AddressOfItem AnItem;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- MarkItem( TheFirstItem );
- MarkItem( GetNextItem(TheFirstItem) );
- MarkItem( TheLastItem );
-
- UnMarkAllItemsInList(TheList);
-
- AnItem = FindFirstMarkedItem( TheList );
- if(AnItem != (AddressOfItem) 0 ) return(1);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindIndexOfFirstMarkedItem
- |
- | PURPOSE: To test the 'FindIndexOfFirstMarkedItem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindIndexOfFirstMarkedItem()
- {
- Truth Result;
- Quad ItemIndex;
-
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- MarkItem( TheLastItem );
-
- ItemIndex = FindIndexOfFirstMarkedItem( TheList );
-
- if(ItemIndex != (Quad) 2 ) return(1);
-
- MarkItem( GetPriorItem(TheLastItem) );
-
- ItemIndex = FindIndexOfFirstMarkedItem( TheList );
-
- if(ItemIndex != (Quad) 1 ) return(2);
-
- MarkItem( TheFirstItem );
-
- ItemIndex = FindIndexOfFirstMarkedItem( TheList );
-
- if(ItemIndex != (Quad) 0 ) return(3);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExtractMarkedItems
- |
- | PURPOSE: To test the 'ExtractMarkedItems' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExtractMarkedItems()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- AList = ExtractMarkedItems( TheList );
- if(IsAnyItemsInList(AList)) return(1);
- DeleteList(AList);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- AList = ExtractMarkedItems( TheList );
- if(GetListItemCount(AList) != (Quad) 1) return(2);
- if(GetFirstItemOfList(AList) != AnItem ) return(3);
- if(TheItemCount != (Quad) 2 ) return(4);
- DeleteList(AList);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- AList = ExtractMarkedItems( TheList );
- if(GetListItemCount(AList) != (Quad) 1) return(5);
- if(GetFirstItemOfList(AList) != AnItem ) return(6);
- if(TheItemCount != (Quad) 1 ) return(7);
- DeleteList(AList);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- AList = ExtractMarkedItems( TheList );
- if(GetListItemCount(AList) != (Quad) 1) return(8);
- if(GetFirstItemOfList(AList) != AnItem ) return(9);
- if(TheItemCount != (Quad) 0 ) return(10);
- DeleteList(AList);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DeleteMarkedItems
- |
- | PURPOSE: To test the 'DeleteMarkedItems' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DeleteMarkedItems()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- DeleteMarkedItems( TheList );
- if(TheItemCount != (Quad) 3) return(1);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- DeleteMarkedItems( TheList );
- if(TheItemCount != (Quad) 2 ) return(2);
- if(TheLastItem == AnItem) return(3);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- DeleteMarkedItems( TheList );
- if(TheItemCount != (Quad) 1 ) return(4);
- if(TheLastItem == AnItem) return(5);
-
- MarkItem( TheLastItem );
- AnItem = TheLastItem;
- DeleteMarkedItems( TheList );
- if(TheItemCount != (Quad) 0 ) return(6);
- if(TheLastItem == AnItem) return(7);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_IsAnyItemMarkedInList
- |
- | PURPOSE: To test the 'IsAnyItemMarkedInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_IsAnyItemMarkedInList()
- {
- AddressOfItem AnItem;
- AddressOfItem LastItem;
- Truth Result;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- Result = IsAnyItemMarkedInList(TheList);
- if(Result) return(1);
-
- MarkItem(TheLastItem);
-
- Result = IsAnyItemMarkedInList(TheList);
- if(!Result) return(1);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DuplicateList
- |
- | PURPOSE: To test the 'DuplicateList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DuplicateList()
- {
- AddressOfList AList;
- AddressOfList BList;
- AddressOfByte FirstDataA;
- AddressOfByte FirstDataB;
- AddressOfByte SecondDataA;
- AddressOfByte SecondDataB;
- AddressOfByte ThirdDataA;
- AddressOfByte ThirdDataB;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- BList = DuplicateList(AList);
-
- TheList = AList;
- FirstDataA = GetItemDataAddress(TheFirstItem);
- SecondDataA = GetItemDataAddress(GetNextItem(TheFirstItem));
- ThirdDataA = GetItemDataAddress(TheLastItem);
-
- TheList = BList;
- FirstDataB = GetItemDataAddress(TheFirstItem);
- SecondDataB = GetItemDataAddress(GetNextItem(TheFirstItem));
- ThirdDataB = GetItemDataAddress(TheLastItem);
-
- if(FirstDataA != FirstDataB) return(1);
- if(SecondDataA != SecondDataB) return(2);
- if(ThirdDataA != ThirdDataB) return(3);
- if(GetListItemCount(AList) != GetListItemCount(BList))
- return(4);
-
- DeleteList(AList);
- DeleteList(BList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_DuplicateMarkedItems
- |
- | PURPOSE: To test the 'DuplicateMarkedItems' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_DuplicateMarkedItems()
- {
- AddressOfList AList;
- AddressOfList BList;
- AddressOfByte FirstDataA;
- AddressOfByte FirstDataB;
- AddressOfByte LastDataA;
- AddressOfByte LastDataB;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- TheList = AList;
- MarkItem(TheFirstItem);
- MarkItem(TheLastItem);
-
- BList = DuplicateMarkedItems(AList);
-
- FirstDataA = GetItemDataAddress(TheFirstItem);
- LastDataA = GetItemDataAddress(TheLastItem);
-
- TheList = BList;
- FirstDataB = GetItemDataAddress(TheFirstItem);
- LastDataB = GetItemDataAddress(TheLastItem);
-
- if(FirstDataA != FirstDataB) return(1);
- if(LastDataA != LastDataB) return(2);
- if(GetListItemCount(BList) != (Quad) 2) return(3);
-
- DeleteList(AList);
- DeleteList(BList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExtractFirstItemFromList
- |
- | PURPOSE: To test the 'ExtractFirstItemFromList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExtractFirstItemFromList()
- {
- AddressOfItem AnItem;
- AddressOfItem FirstItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- FirstItem = TheFirstItem;
-
- AnItem = ExtractFirstItemFromList(TheList);
- if(AnItem != FirstItem) return(1);
- DeleteItem(AnItem);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExtractLastItemFromList
- |
- | PURPOSE: To test the 'ExtractLastItemFromList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExtractLastItemFromList()
- {
- AddressOfItem AnItem;
- AddressOfItem LastItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- LastItem = TheLastItem;
-
- AnItem = ExtractLastItemFromList(TheList);
- if(AnItem != LastItem) return(1);
- DeleteItem(AnItem);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ReverseList
- |
- | PURPOSE: To test the 'ReverseList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ReverseList()
- {
- AddressOfItem FirstItem;
- AddressOfItem MiddleItem;
- AddressOfItem LastItem;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
-
- FirstItem = TheFirstItem;
- MiddleItem = GetNextItem(TheFirstItem);
- LastItem = TheLastItem;
-
- ReverseList(TheList);
-
- if(TheFirstItem != LastItem) return(1);
- if(TheLastItem != FirstItem) return(2);
- if(GetNextItem(TheFirstItem) != MiddleItem) return(3);
- if(TheItemCount != (Quad) 3) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_JoinLists
- |
- | PURPOSE: To test the 'JoinLists' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_JoinLists()
- {
- AddressOfItem FirstItem;
- AddressOfItem LastItem;
- AddressOfList AList;
- AddressOfList BList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- BList = DuplicateList(AList);
-
- FirstItem = GetFirstItemOfList(AList);
- LastItem = GetLastItemOfList(BList);
-
- JoinLists(AList,BList);
-
- TheList = AList;
- if(TheFirstItem != FirstItem) return(1);
- if(TheLastItem != LastItem) return(2);
- if(TheItemCount != (Quad) 6) return(3);
- if(IsAnyItemsInList(BList)) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ExchangeItems
- |
- | PURPOSE: To test the 'ExchangeItems' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ExchangeItems()
- {
- AddressOfItem FirstItem;
- AddressOfItem LastItem;
- AddressOfList AList;
- AddressOfList BList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- InsertDataLastInList(AList,(AddressOfByte)"DDDD");
- /* Now 'AList' has four items. */
-
- TheList = AList;
-
- /* Exchange the first two items, 'AAAA' & 'BBBB'. */
- ExchangeItems(AList,TheFirstItem,GetNextItem(TheFirstItem));
-
- ToFirstItem();
- if(TheDataAddress != BData) return(1);
-
- ToNextItem();
- if(TheDataAddress != AData) return(2);
-
- /* Exchange the what are now the second two items,
- 'AAAA' & 'CCCC'. */
- ExchangeItems(AList,TheItem, GetNextItem(TheItem));
-
- ToFirstItem();
- ToNextItem();
- if(TheDataAddress != CData) return(3);
- ToNextItem();
- if(TheDataAddress != AData) return(4);
-
- /* Exchange the what are now the last two items,
- 'AAAA' & 'DDDD'. */
- ExchangeItems(AList,TheItem, TheLastItem);
- ToLastItem();
- if(TheDataAddress != AData) return(5);
- ToPriorItem();
- if(TheDataAddress[0] != (Byte) 'D') return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertItemFirstInList
- |
- | PURPOSE: To test the 'InsertItemFirstInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertItemFirstInList()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "Existence is identity.";
- FirstItem = CreateItemForData(SomeData);
- InsertItemFirstInList(TheList,FirstItem);
-
- if(TheItemCount != 1) return(1);
- if(TheFirstItem != FirstItem) return(2);
- if(TheLastItem != FirstItem) return(3);
-
- SomeData = (AddressOfByte) "Consciousness is identification.";
- SecondItem = CreateItemForData(SomeData);
- InsertItemFirstInList(TheList,SecondItem);
-
- if(TheItemCount != 2) return(4);
- if(TheLastItem != FirstItem) return(5);
- if(TheFirstItem != SecondItem) return(6);
- if(GetNextItem(SecondItem) != FirstItem) return(7);
- if(GetPriorItem(FirstItem) != SecondItem) return(8);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertItemAfterItemInList
- |
- | PURPOSE: To test the 'InsertItemAfterItemInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertItemAfterItemInList()
- {
- Byte DData[]="DDDD";
- AddressOfList AList;
- AddressOfItem AnItem;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- TheList = AList;
- AnItem = CreateItemForData(DData);
- InsertItemAfterItemInList(AList,TheFirstItem,AnItem);
- /* Now 'AList' has four items:
- {'AAAA','DDDD','BBBB','CCCC'}
- */
-
- if(TheItemCount != 4) return(1);
-
- ToFirstItem();
- ToNextItem();
- if(TheItem != AnItem) return(2);
-
- ToPriorItem();
- if(TheItem != TheFirstItem) return(3);
-
- AnItem = CreateItemForData(DData);
- InsertItemAfterItemInList(AList,TheLastItem,AnItem);
- /* Now 'AList' has five items:
- {'AAAA','DDDD','BBBB','CCCC','DDDD'}
- */
- ToLastItem();
- if(TheItem != AnItem) return(4);
- ToPriorItem();
- if(TheDataAddress != CData) return(5);
- ToNextItem();
- if(TheItem != AnItem) return(6);
-
- AnItem = CreateItemForData(DData);
- InsertItemAfterItemInList(AList,(AddressOfItem)0,AnItem);
- /* Now 'AList' has six items:
- {'DDDD','AAAA','DDDD','BBBB','CCCC','DDDD'}
- */
- ToFirstItem();
- if(TheItem != AnItem) return(7);
- ToNextItem();
- if(TheDataAddress != AData) return(8);
- ToPriorItem();
- if(TheItem != AnItem) return(9);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertItemBeforeItemInList
- |
- | PURPOSE: To test the 'InsertItemBeforeItemInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertItemBeforeItemInList()
- {
- Byte DData[]="DDDD";
- AddressOfItem AnItem;
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- TheList = AList;
- AnItem = CreateItemForData(DData);
- InsertItemBeforeItemInList(AList,TheLastItem,AnItem);
- /* Now 'AList' has four items:
- {'AAAA','BBBB','DDDD','CCCC'}
- */
-
- if(TheItemCount != 4) return(1);
-
- ToLastItem();
- ToPriorItem();
- if(TheItem != AnItem) return(2);
-
- ToNextItem();
- if(TheItem != TheLastItem) return(3);
-
- AnItem = CreateItemForData(DData);
- InsertItemBeforeItemInList(AList,TheFirstItem,AnItem);
- /* Now 'AList' has five items:
- {'DDDD','AAAA','BBBB','DDDD','CCCC'}
- */
- ToFirstItem();
- if(TheItem != AnItem) return(4);
- ToNextItem();
- if(TheDataAddress != AData) return(5);
- ToPriorItem();
- if(TheItem != AnItem) return(6);
-
- AnItem = CreateItemForData(DData);
- InsertItemBeforeItemInList(AList,(AddressOfItem) 0,AnItem);
- /* Now 'AList' has six items:
- {'DDDD','AAAA','BBBB','DDDD','CCCC','DDDD'}
- */
- ToLastItem();
- if(TheItem != AnItem) return(7);
- ToPriorItem();
- if(TheDataAddress != CData) return(8);
- ToNextItem();
- if(TheItem != AnItem) return(9);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertDataFirstInList
- |
- | PURPOSE: To test the 'InsertDataFirstInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertDataFirstInList()
- {
- AddressOfItem FirstItem;
- AddressOfItem SecondItem;
- AddressOfByte SomeData;
-
- PushTheListAndItem();
-
- TheList = CreateList();
-
- SomeData = (AddressOfByte) "Existence is identity.";
- InsertDataFirstInList(TheList, SomeData);
-
- ToFirstItem();
- if(TheDataAddress != SomeData) return(1);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertDataAfterItemInList
- |
- | PURPOSE: To test the 'InsertDataAfterItemInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertDataAfterItemInList()
- {
- Byte DData[]="DDDD";
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- TheList = AList;
-
- InsertDataAfterItemInList(AList,TheFirstItem,DData);
- /* Now 'AList' has four items:
- {'AAAA','DDDD','BBBB','CCCC'}
- */
-
- ToFirstItem();
- ToNextItem();
- if(TheDataAddress != DData) return(1);
-
- InsertDataAfterItemInList(AList,TheLastItem,DData);
- /* Now 'AList' has five items:
- {'AAAA','DDDD','BBBB','CCCC','DDDD'}
- */
- ToLastItem();
- if(TheDataAddress != DData) return(2);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertDataBeforeItemInList
- |
- | PURPOSE: To test the 'InsertDataBeforeItemInList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertDataBeforeItemInList()
- {
- Byte DData[]="DDDD";
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- TheList = AList;
-
- InsertDataBeforeItemInList(AList,TheLastItem,DData);
- /* Now 'AList' has four items:
- {'AAAA','BBBB','DDDD','CCCC'}
- */
-
- ToLastItem();
- ToPriorItem();
- if(TheDataAddress != DData) return(1);
-
- InsertDataBeforeItemInList(AList,TheFirstItem,DData);
- /* Now 'AList' has five items:
- {'DDDD','AAAA','BBBB','DDDD','CCCC'}
- */
- ToFirstItem();
- if(TheDataAddress != DData) return(2);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_BuildDirectAccessTableForList
- |
- | PURPOSE: To test the 'BuildDirectAccessTableForList'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.19.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_BuildDirectAccessTableForList()
- {
- AddressOfList AList;
- AddressOfAddressOfItem ATable;
-
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- ATable = BuildDirectAccessTableForList(AList);
-
- TheList = AList;
- ToFirstItem();
- if(TheItem != ATable[0]) return(1);
-
- ToNextItem();
- if(TheItem != ATable[1]) return(2);
-
- ToNextItem();
- if(TheItem != ATable[2]) return(3);
-
- FreeMemory(ATable);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindPlaceInOrderedList
- |
- | PURPOSE: To test the 'FindPlaceInOrderedList'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindPlaceInOrderedList()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
-
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- TheList = AList;
-
- AnItem = FindPlaceInOrderedList(AList,
- (AddressOfByte) "A",
- CompareStrings);
-
- ToFirstItem();
- if(AnItem != TheItem ) return(1);
-
- AnItem = FindPlaceInOrderedList(AList,
- (AddressOfByte) "B",
- CompareStrings);
-
- ToNextItem();
- if(AnItem != TheItem) return(2);
-
- AnItem = FindPlaceInOrderedList(AList,
- (AddressOfByte) "C",
- CompareStrings);
-
- ToNextItem();
- if(AnItem != TheItem) return(3);
-
- AnItem = FindPlaceInOrderedList(AList,
- (AddressOfByte) "D",
- CompareStrings);
-
- if(AnItem != (AddressOfItem) 0) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_InsertDataInOrderedList
- |
- | PURPOSE: To test the 'InsertDataInOrderedList'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_InsertDataInOrderedList()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
-
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- /* This is what the list looks like: */
- /* { 'AAAA', 'BBBB', 'CCCC' } */
-
- TheList = AList;
-
- AnItem = InsertDataInOrderedList(AList,
- (AddressOfByte) "A",
- CompareStrings);
- /* { 'A', 'AAAA', 'BBBB', 'CCCC' } */
-
- ToFirstItem();
- if(AnItem != TheItem ) return(1);
-
- AnItem = InsertDataInOrderedList(AList,
- (AddressOfByte) "B",
- CompareStrings);
-
- /* { 'A', 'AAAA', 'B', 'BBBB', 'CCCC' } */
- ToFirstItem();
- ToNextItem();
- ToNextItem();
- if(AnItem != TheItem) return(2);
-
- AnItem = InsertDataInOrderedList(AList,
- (AddressOfByte) "C",
- CompareStrings);
-
- /* { 'A', 'AAAA', 'B', 'BBBB', 'C', 'CCCC' } */
-
- ToFirstItem();
- ToNextItem();
- ToNextItem();
- ToNextItem();
- ToNextItem();
- if(AnItem != TheItem) return(3);
-
- AnItem = InsertDataInOrderedList(AList,
- (AddressOfByte) "D",
- CompareStrings);
- /* { 'A', 'AAAA', 'B', 'BBBB', 'C', 'CCCC','D' } */
-
-
- ToLastItem();
- if(AnItem != AnItem) return(4);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_FindPlaceInOrderedDirectAccessTable
- |
- | PURPOSE: To test the 'FindPlaceInOrderedDirectAccessTable'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_FindPlaceInOrderedDirectAccessTable()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
- AddressOfAddressOfItem ATable;
- AddressOfAddressOfItem AnEntry;
-
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- ATable = BuildDirectAccessTableForList(AList);
-
- TheList = AList;
-
- AnEntry = FindPlaceInOrderedDirectAccessTable(
- ATable,
- (Quad) TheItemCount,
- (AddressOfByte) "A",
- CompareStrings);
-
- if(AnEntry != &ATable[0] ) return(1);
-
- AnEntry = FindPlaceInOrderedDirectAccessTable(
- ATable,
- (Quad) TheItemCount,
- (AddressOfByte) "B",
- CompareStrings);
-
- if(AnEntry != &ATable[1] ) return(2);
-
- AnEntry = FindPlaceInOrderedDirectAccessTable(
- ATable,
- (Quad) TheItemCount,
- (AddressOfByte) "C",
- CompareStrings);
-
- if(AnEntry != &ATable[2] ) return(3);
-
-
- AnEntry = FindPlaceInOrderedDirectAccessTable(
- ATable,
- (Quad) TheItemCount,
- (AddressOfByte) "D",
- CompareStrings);
-
- if(AnEntry != (AddressOfAddressOfItem) 0 ) return(4);
-
- FreeMemory(ATable);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_ReorderListToMatchDirectAccessTable
- |
- | PURPOSE: To test the 'ReorderListToMatchDirectAccessTable'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_ReorderListToMatchDirectAccessTable()
- {
- AddressOfList AList;
- AddressOfAddressOfItem ATable;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
- ATable = BuildDirectAccessTableForList(AList);
-
- ReverseList(AList);
-
- ReorderListToMatchDirectAccessTable( AList, ATable);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- FreeMemory(ATable);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortShortList
- |
- | PURPOSE: To test the 'SortShortList'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortShortList()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- ReverseList(AList);
-
- SortShortList(AList,CompareStrings);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortDirectAccessTable
- |
- | PURPOSE: To test the 'SortDirectAccessTable'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortDirectAccessTable()
- {
- AddressOfList AList;
- AddressOfItem DATable[] = {0,0,0,0,0};
- AddressOfAddressOfItem ATable;
-
- PushTheListAndItem();
-
- ATable = &DATable[1];
-
- AList = MakeSampleListOfStaticStrings();
- ReverseList(AList);
-
- TheList = AList;
- ToFirstItem();
- DATable[1] = TheItem;
- ToNextItem();
- DATable[2] = TheItem;
- ToNextItem();
- DATable[3] = TheItem;
-
- SortDirectAccessTable( ATable,
- (Quad) 3,
- CompareStrings);
-
- ReorderListToMatchDirectAccessTable(AList, ATable);
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- if(DATable[0] != (AddressOfItem) 0) return(7);
- if(DATable[4] != (AddressOfItem) 0) return(8);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortListViaDirectAccessTable
- |
- | PURPOSE: To test the 'SortListViaDirectAccessTable'
- | procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.21.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortListViaDirectAccessTable()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- ReverseList(AList);
-
- SortListViaDirectAccessTable(AList,CompareStrings);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortList
- |
- | PURPOSE: To test the 'SortList' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortList()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- ReverseList(AList);
-
- DirectAccessTableThreshold = 20;
- /* Use SortShortList(). */
- SortList(AList,CompareStrings);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- ReverseList(AList);
-
- DirectAccessTableThreshold = 2;
- /* Use SortListViaDirectAccessTable(). */
- SortList(AList,CompareStrings);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortListAlphabetically
- |
- | PURPOSE: To test the 'SortListAlphabetically' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortListAlphabetically()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- ReverseList(AList);
-
- DirectAccessTableThreshold = 20;
- /* Use SortShortList(). */
- SortListAlphabetically(AList);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- ReverseList(AList);
-
- DirectAccessTableThreshold = 2;
- /* Use SortListViaDirectAccessTable(). */
- SortListAlphabetically(AList);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_SortListDescending
- |
- | PURPOSE: To test the 'SortListDescending' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_SortListDescending()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- AList = MakeSampleListOfStaticStrings();
-
- DirectAccessTableThreshold = 20;
- /* Use SortShortList(). */
- SortListDescending(AList,CompareStrings);
-
- ReverseList(AList);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DirectAccessTableThreshold = 2;
- /* Use SortListViaDirectAccessTable(). */
- SortListDescending(AList,CompareStrings);
-
- ReverseList(AList);
-
- TheList = AList;
-
- ToFirstItem();
- if(TheDataAddress != AData) return(1);
- ToNextItem();
- if(TheDataAddress != BData) return(2);
- ToNextItem();
- if(TheDataAddress != CData) return(3);
-
- ToLastItem();
- if(TheDataAddress != CData) return(4);
- ToPriorItem();
- if(TheDataAddress != BData) return(5);
- ToPriorItem();
- if(TheDataAddress != AData) return(6);
-
- DeleteList(TheList);
-
- PullTheListAndItem();
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_OutputListOfStrings
- |
- | PURPOSE: To test the 'OutputListOfStrings' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_OutputListOfStrings()
- {
- AddressOfList AList;
-
- AList = MakeSampleListOfStaticStrings();
-
- printf("The following list should show three strings,\n");
- printf("one per line, 'AAAA', 'BBBB', 'CCCC'.\n\n");
-
- fprintf(LogFile,"The following list should show three strings,\n");
- fprintf(LogFile,"one per line: 'AAAA', 'BBBB', 'CCCC'.\n\n");
-
- OutputListOfStrings(AList, stdout);
- OutputListOfStrings(AList, LogFile);
-
- ReverseList(AList);
-
- printf("And now the same strings in reverse order:\n");
- fprintf(LogFile,"And now the same strings in reverse order:\n");
-
- OutputListOfStrings(AList, stdout);
- OutputListOfStrings(AList, LogFile);
-
- printf("Visually verify the above.\n");
- fprintf(LogFile,"Visually verify the above.\n");
-
- DeleteList(AList);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_OutputListSystemStatus
- |
- | PURPOSE: To test the 'OutputListSystemStatus' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_OutputListSystemStatus()
- {
- AddressOfList AList;
-
- PushTheListAndItem();
-
- TheList = MakeSampleListOfStaticStrings();
- ToFirstItem();
-
- printf("\nThe following should show the status of the list system\n");
- printf("with one list in use and three items in use.\n");
-
- fprintf(LogFile,
- "\nThe following should show the status of the list system\n");
- fprintf(LogFile,"with one list in use and three items in use.\n");
-
- OutputListSystemStatus(stdout);
- OutputListSystemStatus(LogFile);
-
- printf("Visually verify the above.\n");
- fprintf(LogFile,"Visually verify the above.\n");
-
- DeleteList(TheList);
-
- return(False);
- }
-
- /*------------------------------------------------------------
- | NAME: Test_CleanUpTheListSystem
- |
- | PURPOSE: To test the 'CleanUpTheListSystem' procedure.
- |
- | DESCRIPTION: Returns non-zero if error detected.
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: State after prior tests.
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Truth
- Test_CleanUpTheListSystem()
- {
- CleanUpTheListSystem();
-
- if( TheListSystemIsSetUp ) return(1);
- if( TheListStackIndex != 0 ) return(2);
- if( MaxCountOfLists != 0 ) return(3);
- if( MaxCountOfItems != 0 ) return(4);
- if( ListSpace != 0 ) return(5);
- if( ItemSpace != 0 ) return(6);
- if( CountOfFreeItems != 0 ) return(7);
- if( CountOfFreeLists != 0 ) return(8);
- if( FirstFreeList != 0 ) return(9);
- if( FirstFreeItem != 0 ) return(10);
-
- return(False);
- }
-
-
- /* Test order is important: later tests depend on earlier ones. */
- TestRecord ListTestSequence[] =
- {
- /* From 'DataSize.h' */
- { Test_Byte, "DataSize: Byte" },
- { Test_Pair, "DataSize: Pair" },
- { Test_Quad, "DataSize: Quad" },
- { Test_SignedByte, "DataSize: SignedByte" },
- { Test_SignedPair, "DataSize: SignedPair" },
- { Test_SignedQuad, "DataSize: SignedQuad" },
- /* From 'Bytes.c' */
- { Test_CompareBytes, "CompareBytes" },
- { Test_CopyBytes, "CopyBytes" },
- { Test_ExchangeBytes, "ExchangeBytes" },
- { Test_FillBytes, "FillBytes" },
- { Test_IsMatchingBytes, "IsMatchingBytes" },
- { Test_ReplaceBytes, "ReplaceBytes" },
- /* From 'Strings.c' */
- { Test_CountString, "CountString" },
- { Test_CopyString, "CopyString" },
- { Test_AppendString, "AppendString" },
- { Test_AppendStrings, "AppendStrings" },
- { Test_ConvertStringToLowerCase, "ConvertStringToLowerCase" },
- { Test_ConvertStringToUpperCase, "ConvertStringToUpperCase" },
- { Test_CompareStrings, "CompareStrings" },
- { Test_FindLastByteInString, "FindLastByteInString" },
- { Test_InsertString, "InsertString" },
- { Test_ReplaceByteInString, "ReplaceByteInString" },
- /* From 'ListList.c' */
- { Test_GetNextItem, "GetNextItem" },
- { Test_PutNextItem, "PutNextItem" },
- { Test_TheNextItem, "TheNextItem" },
- { Test_GetPriorItem, "GetPriorItem" },
- { Test_PutPriorItem, "PutPriorItem" },
- { Test_ThePriorItem, "ThePriorItem" },
- { Test_GetItemDataAddress, "GetItemDataAddress" },
- { Test_PutItemDataAddress, "PutItemDataAddress" },
- { Test_TheDataAddress, "TheDataAddress" },
- { Test_GetItemMark, "GetItemMark" },
- { Test_PutItemMark, "PutItemMark" },
- { Test_TheItemMark, "TheItemMark" },
- { Test_GetFirstItemOfList, "GetFirstItemOfList" },
- { Test_PutFirstItemOfList, "PutFirstItemOfList" },
- { Test_TheFirstItem, "TheFirstItem" },
- { Test_GetLastItemOfList, "GetLastItemOfList" },
- { Test_PutLastItemOfList, "PutLastItemOfList" },
- { Test_TheLastItem, "TheLastItem" },
- { Test_GetListItemCount, "GetListItemCount" },
- { Test_PutListItemCount, "PutListItemCount" },
- { Test_TheItemCount, "TheItemCount" },
- { Test_GetListMark, "GetListMark" },
- { Test_PutListMark, "PutListMark" },
- { Test_TheListMark, "TheListMark" },
- { Test_MarkItem, "MarkItem" },
- { Test_UnMarkItem, "UnMarkItem" },
- { Test_IsItemMarked, "IsItemMarked" },
- { Test_MarkList, "MarkList" },
- { Test_UnMarkList, "UnMarkList" },
- { Test_IsListMarked, "IsListMarked" },
- { Test_MarkItemAsFirst, "MarkItemAsFirst" },
- { Test_IsItemFirst, "IsItemFirst" },
- { Test_MarkItemAsLast, "MarkItemAsLast" },
- { Test_IsItemLast, "IsItemLast" },
- { Test_IsItemAlone, "IsItemAlone" },
- { Test_ToNextItem, "ToNextItem" },
- { Test_ToPriorItem, "ToPriorItem" },
- { Test_ToFirstItem, "ToFirstItem" },
- { Test_ToLastItem, "ToLastItem" },
- { Test_SetUpTheListSystem, "SetUpTheListSystem" },
- { Test_PushTheItem, "PushTheItem" },
- { Test_PullTheItem, "PullTheItem" },
- { Test_PushTheList, "PushTheList" },
- { Test_PullTheList, "PullTheList" },
- { Test_PushTheListAndItem, "PushTheListAndItem" },
- { Test_PullTheListAndItem, "PullTheListAndItem" },
- { Test_MarkListAsEmpty, "MarkListAsEmpty" },
- { Test_IsAnyItemsInList, "IsAnyItemsInList" },
- { Test_IsItemCreationPossible, "IsItemCreationPossible" },
- { Test_IsListCreationPossible, "IsListCreationPossible" },
- { Test_CreateItem, "CreateItem" },
- { Test_DeleteItem, "DeleteItem" },
- { Test_CreateItemForData, "CreateItemForData" },
- { Test_CreateList, "CreateList" },
- { Test_CreateList, "CreateList" },
- { Test_AddToListItemCount, "AddToListItemCount" },
- { Test_InsertItemLastInList, "InsertItemLastInList" },
- { Test_InsertDataLastInList, "InsertDataLastInList" },
- { Test_ExtractTheItem, "ExtractTheItem" },
- { Test_ExtractItemFromList, "ExtractItemFromList" },
- { Test_DeleteList, "DeleteList" },
- { Test_DeleteListOfDynamicData, "DeleteListOfDynamicData" },
- { Test_FindFirstItemLinkedToData, "FindFirstItemLinkedToData" },
- { Test_DeleteFirstReferenceToData, "DeleteFirstReferenceToData" },
- { Test_DeleteAllReferencesToData, "DeleteAllReferencesToData" },
- { Test_IsTheDataMatching, "IsTheDataMatching" },
- { Test_FindFirstMatchingItem, "FindFirstMatchingItem" },
- { Test_FindNextMatchingItem, "FindNextMatchingItem" },
- { Test_FindFirstMarkedItem, "FindFirstMarkedItem" },
- { Test_FindFirstUnMarkedItem, "FindFirstUnMarkedItem" },
- { Test_UnMarkAllItemsInList, "UnMarkAllItemsInList" },
- { Test_FindIndexOfFirstMarkedItem, "FindIndexOfFirstMarkedItem" },
- { Test_ExtractMarkedItems, "ExtractMarkedItems" },
- { Test_DeleteMarkedItems, "DeleteMarkedItems" },
- { Test_IsAnyItemMarkedInList, "IsAnyItemMarkedInList" },
- { Test_DuplicateList, "DuplicateList" },
- { Test_DuplicateMarkedItems, "DuplicateMarkedItems" },
- { Test_ExtractFirstItemFromList, "ExtractFirstItemFromList" },
- { Test_ExtractLastItemFromList, "ExtractLastItemFromList" },
- { Test_ReverseList, "ReverseList" },
- { Test_JoinLists, "JoinLists" },
- { Test_ExchangeItems, "ExchangeItems" },
- { Test_InsertItemFirstInList, "InsertItemFirstInList" },
- { Test_InsertItemAfterItemInList, "InsertItemAfterItemInList" },
- { Test_InsertItemBeforeItemInList, "InsertItemBeforeItemInList" },
- { Test_InsertDataFirstInList, "InsertDataFirstInList" },
- { Test_InsertDataAfterItemInList, "InsertDataAfterItemInList" },
- { Test_InsertDataBeforeItemInList, "InsertDataBeforeItemInList" },
- { Test_BuildDirectAccessTableForList, "BuildDirectAccessTableForList" },
- { Test_FindPlaceInOrderedList, "FindPlaceInOrderedList" },
- { Test_InsertDataInOrderedList, "InsertDataInOrderedList" },
- { Test_FindPlaceInOrderedDirectAccessTable, "FindPlaceInOrderedDirectAccessTable" },
- { Test_ReorderListToMatchDirectAccessTable, "ReorderListToMatchDirectAccessTable" },
- { Test_SortShortList, "SortShortList" },
- { Test_SortDirectAccessTable, "SortDirectAccessTable" },
- { Test_SortListViaDirectAccessTable, "SortListViaDirectAccessTable" },
- { Test_SortList, "SortList" },
- { Test_SortListAlphabetically, "SortListAlphabetically" },
- { Test_SortListDescending, "SortListDescending" },
- { Test_OutputListOfStrings, "OutputListOfStrings" },
- { Test_OutputListSystemStatus, "OutputListSystemStatus" },
- { Test_CleanUpTheListSystem, "CleanUpTheListSystem" }
- };
-
- /*------------------------------------------------------------
- | NAME: RunTestSequence
- |
- | PURPOSE: To run the tests in the given table.
- |
- | DESCRIPTION:
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: 'LogFile' is open for writing.
- |
- | HISTORY: 11.06.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Nothing
- RunTestSequence(AddressOfTestRecord Tests, Quad CountOfTests )
- {
- Truth TestResult;
- AddressOfString ProcedureName;
- Quad i;
-
- for( i = 0; i < CountOfTests; i++ )
- {
- ProcedureName = Tests[i].NameOfProcedure;
-
- printf("[%ld] Testing: %s\n",i+1,ProcedureName);
- fprintf(LogFile,"[%ld] Testing: %s\n",i+1,ProcedureName);
-
- TestResult = (*Tests[i].TestProcedure)();
-
- if(TestResult) /* if there was an error */
- {
- printf("...FAILED in section # %d.\n\n",TestResult);
- fprintf(LogFile,"...FAILED in section # %d.\n\n",TestResult);
-
- printf("*********************************************\n");
- printf("* F A I L U R E D E T E C T E D *\n");
- printf("* *\n");
- printf("* Repair above item and repeat test. *\n");
- printf("* *\n");
- printf("*********************************************\n");
-
- fprintf(LogFile,"*********************************************\n");
- fprintf(LogFile,"* F A I L U R E D E T E C T E D *\n");
- fprintf(LogFile,"* *\n");
- fprintf(LogFile,"* Repair above item and repeat test. *\n");
- fprintf(LogFile,"* *\n");
- fprintf(LogFile,"*********************************************\n");
-
- fclose(LogFile);
- exit(1);
- }
- else /* no error. */
- {
- printf("...OK.\n\n");
- fprintf(LogFile,"...OK.\n\n");
- }
- if(MaxCountOfItems-CountOfFreeItems)
- fprintf(LogFile,"ItemsInUse: %ld",(MaxCountOfItems-CountOfFreeItems));
- }
- }
-
- /*------------------------------------------------------------
- | NAME: ListListDemonstration
- |
- | PURPOSE: To demonstrate some 'ListList' functions.
- |
- | DESCRIPTION:
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES:
- |
- | HISTORY: 11.22.93 by Lee Malone
- |
- ------------------------------------------------------------*/
- Nothing
- ListListDemonstration()
- {
- AddressOfList AList;
- AddressOfItem AnItem;
- AddressOfByte SomeData;
- AddressOfByte SearchKey;
- Pair KeyFieldOffset;
- Pair KeyFieldWidth;
-
- /* These are the data elements to be itemized. */
- Byte John[] = "John Galt";
- Byte Dagny[] = "Dagny Taggart";
- Byte Hank[] = "Hank Reardon";
- Byte Frisco[] = "Francisco d'Anconia";
- Byte Hugh[] = "Hugh Akston";
-
- printf("Set up the list system:\n");
- fprintf(LogFile,"Set up the list system:\n");
- SetUpTheListSystem((Quad) 30, (Quad) 100);
- OutputListSystemStatus(stdout);
- OutputListSystemStatus(LogFile);
-
-
- printf("\nCreate a list of five names:\n");
- fprintf(LogFile,"\nCreate a list of five names:\n");
-
- AList = CreateList();
-
- InsertDataLastInList( AList, John );
- InsertDataLastInList( AList, Dagny );
- InsertDataLastInList( AList, Hank );
- InsertDataLastInList( AList, Frisco );
- InsertDataLastInList( AList, Hugh );
-
- OutputListOfStrings(AList,stdout);
- OutputListOfStrings(AList,LogFile);
-
- printf("Reverse the list:\n");
- fprintf(LogFile,"Reverse the list:\n");
- ReverseList(AList);
- OutputListOfStrings(AList,stdout);
- OutputListOfStrings(AList,LogFile);
-
- printf("Sort the list alphabetically:\n");
- fprintf(LogFile,"Sort the list alphabetically:\n");
- SortListAlphabetically(AList);
- OutputListOfStrings(AList,stdout);
- OutputListOfStrings(AList,LogFile);
-
- printf("Find and print the name starting with 'John':\n");
- fprintf(LogFile,"Find and print the name starting with 'John':\n");
-
- SearchKey = (AddressOfByte) "John";
- KeyFieldOffset = 0;
- KeyFieldWidth = 4;
-
- AnItem = FindFirstMatchingItem(AList,
- KeyFieldOffset,
- KeyFieldWidth,
- SearchKey);
-
- SomeData = GetItemDataAddress(AnItem);
-
- printf("%s\n\n",(AddressOfString) SomeData);
- fprintf(LogFile,"%s\n\n",(AddressOfString) SomeData);
-
- DeleteList(AList);
-
- printf("Clean up the list system:\n");
- fprintf(LogFile,"Clean up the list system:\n");
- CleanUpTheListSystem();
- OutputListSystemStatus(stdout);
- OutputListSystemStatus(LogFile);
- }
-
- /*------------------------------------------------------------
- | NAME: main
- |
- | PURPOSE: To test list functions.
- |
- | DESCRIPTION:
- |
- | EXAMPLE:
- |
- | NOTE:
- |
- | ASSUMES: Room exists for the log file on disk.
- |
- | HISTORY: 01.09.88 by Lee Malone
- | 11.08.93 extended
- |
- ------------------------------------------------------------*/
- Nothing
- main()
- {
- Quad CountOfTests;
-
- printf("*********************************************\n");
- printf("* B E G I N L I S T L I S T T E S T S *\n");
- printf("*********************************************\n");
-
- LogFile = fopen("ListTest.txt", "w+");
-
- fprintf(LogFile,"*********************************************\n");
- fprintf(LogFile,"* B E G I N L I S T L I S T T E S T S *\n");
- fprintf(LogFile,"*********************************************\n");
-
- /*
- * Test the list system procedures.
- */
- CountOfTests = sizeof(ListTestSequence)/sizeof(TestRecord);
- RunTestSequence(ListTestSequence, CountOfTests);
-
- printf("***************************************************\n");
- printf("* A L L T E S T S C O M P L E T E D O K *\n");
- printf("* *\n");
- printf("* 'ListList' is ready to use. *\n");
- printf("* *\n");
- printf("***************************************************\n\n");
-
- fprintf(LogFile,"***************************************************\n");
- fprintf(LogFile,"* A L L T E S T S C O M P L E T E D O K *\n");
- fprintf(LogFile,"* *\n");
- fprintf(LogFile,"* 'ListList' is ready to use. *\n");
- fprintf(LogFile,"* *\n");
- fprintf(LogFile,"***************************************************\n\n");
-
- printf("*********************************************\n");
- printf("* B E G I N L I S T L I S T D E M O *\n");
- printf("*********************************************\n");
-
- fprintf(LogFile,"*********************************************\n");
- fprintf(LogFile,"* B E G I N L I S T L I S T D E M O *\n");
- fprintf(LogFile,"*********************************************\n");
-
- ListListDemonstration();
-
- printf("*********************************************\n");
- printf("* E N D L I S T L I S T D E M O *\n");
- printf("*********************************************\n");
-
- fprintf(LogFile,"*********************************************\n");
- fprintf(LogFile,"* E N D L I S T L I S T D E M O *\n");
- fprintf(LogFile,"*********************************************\n");
-
- fclose(LogFile);
- }
-